<!--钢筋保护层检测---钢筋保护层检测-1---编辑-->
<template>
  <div class="department">
    <!-- 右侧 -->
    <div class="department_right">
      <!-- 顶部导航栏 -->
      <div class="mechanism_nav">
        <!-- 左侧 -->
        <div class="mechanism_nav_left">
          <el-radio-group v-model="radio" size="small" @change="modelType($event)">
            <el-radio-button label="待办"></el-radio-button>
            <el-radio-button label="已办"></el-radio-button>
            <!-- #2b5a9d -->
          </el-radio-group>
        </div>
        <!-- 顶部按钮 -->
        <div class="print">
          <div class="printTable">
            <el-button type="primary" v-if="getList.modelType == 0 && yj_edit == true" icon="el-icon-edit" size="small"
              @click="engineerings(1)">编辑</el-button>
            <el-button type="primary" v-if="getList.modelType == 0 && yj_submit == true" icon="el-icon-circle-check"
              size="small" @click="SubmitText(equipmentDetailId)">提交
            </el-button>
          </div>
        </div>
      </div>
      <!-- 表格 -->
      <div class="text_table mechanism_Table">
        <el-table ref="multipleTable" :data="tableData" style="width: 100%"
          :height="navigatepageNums > 1 ? 'calc(100% - 50px)' : '100%'" default-expand-all
          :tree-props="{ children: 'children', hasChildren: 'hasChildren' }" row-key="F_CompanyId" v-loading="loading"
          element-loading-text="拼命加载中" element-loading-spinner="el-icon-loading"
          element-loading-background="rgba(0, 0, 0, 0.2)" :row-class-name="tableRowClassName" border stripe
          highlight-current-row @current-change="handleCurrentChange" @row-click="getRowInfo">
          <el-table-column fixed type="index" label="序号" width="50" align="center"></el-table-column>
          <el-table-column prop="fProjectname" label="建设项目简称" width="180">
            <template slot-scope="scope">
              <div class="lineBoxhidden">
                <a href="javascript:;" :title="scope.row.fProjectname">{{
                  scope.row.fProjectname
                }}</a>
              </div>
            </template>
          </el-table-column>
          <el-table-column prop="fCompanyname" label="施工/委托单位" width="115" align="left">
            <template slot-scope="scope">
              <div class="lineBoxhidden">
                <a href="javascript:;" :title="scope.row.fCompanyname">{{
                  scope.row.fCompanyname
                }}</a>
              </div>
            </template>
          </el-table-column>
          <el-table-column prop="fSamplingno" label="样品编号" width="210" align="center">
            <template slot-scope="scope">
              <el-button @click="openDialog(scope.row)" @cell-dblclick="openDialog" type="text" size="small">
                {{ scope.row.fSamplingno }}
              </el-button>
            </template>
          </el-table-column>
          <el-table-column prop="fProjecttypename" label="工程部位/用途" width="150">
            <template slot-scope="scope">
              <div class="lineBoxhidden">
                <a href="javascript:;" :title="scope.row.fProjecttypename">{{
                  scope.row.fProjecttypename
                }}</a>
              </div>
            </template>
          </el-table-column>
          <el-table-column prop="fConcretelevel" label="强度等级" align="center" width="69">
          </el-table-column>
          <el-table-column prop="fSpecimenage" label="龄期(天)" align="center" width="68">
            <template slot-scope="scope">
              <div class="lineBoxhidden">
                <a href="javascript:;" :title="scope.row.fSpecimenage">{{
                  scope.row.fSpecimenage
                }}</a>
              </div>
            </template>
          </el-table-column>
          <el-table-column prop="fConcreteresult" label="强度测定值(MPa)" align="center" width="115">
            <template slot-scope="scope">
              <div class="lineBoxhidden">
                <a href="javascript:;" :title="scope.row.fConcreteresult">{{
                  scope.row.fConcreteresult
                }}</a>
              </div>
            </template>
          </el-table-column>

          <el-table-column prop="fTestnum" label="达到设计强度(%)" align="center" width="125">
          </el-table-column>
          <el-table-column prop="fIstrue" label="是否合格" width="70" align="center">
          </el-table-column>
          <el-table-column prop="fTestdates" label="试验日期" width="88" align="center">
          </el-table-column>
          <el-table-column prop="fIsconcrete" label="是否回弹检测" width="95" align="center">
          </el-table-column>
          <el-table-column prop="fChecktype" label="检测类型" width="95">
          </el-table-column>
          <el-table-column prop="fLeadercompanyname" label="检测单位" width="105">
            <template slot-scope="scope">
              <div class="lineBoxhidden">
                <a href="javascript:;" :title="scope.row.fLeadercompanyname">{{
                  scope.row.fLeadercompanyname
                }}</a>
              </div>
            </template>
          </el-table-column>

          <el-table-column prop="fReportdates" label="回弹时间" width="90" align="center">
          </el-table-column>
          <el-table-column prop="fTestresult" label="回弹检测结果" width="100" align="center">
          </el-table-column>
          <el-table-column prop="fCreateusername" label="记录人" width="70" align="center">
          </el-table-column>
          <el-table-column prop="fPhotofilelists" label="记录表" width="100" align="center">
            <template slot-scope="scope">
              <div style="display: flex; height: 100%; align-items: center">
                <div v-for="(v, index) in scope.row.fPhotofilelists" @click="openPdfs1(v)" :key="index"
                  style="margin: 2px 3px; display: flex; align-items: center">
                  <img style="
                          max-width: 100%;
                          max-height: 100%;
                          width: 18px;
                          height: 20px;
                        " src="@/assets/img/pdf.png" />
                </div>
              </div>
            </template>
          </el-table-column>
          <el-table-column prop="fSourcefilelists" label="检测报告" width="100" align="center">
            <template slot-scope="scope">
              <div style="display: flex; height: 100%; align-items: center">
                <div v-for="(v, index) in scope.row.fSourcefilelists" @click="openPdfs1(v)" :key="index"
                  style="margin: 2px 3px; display: flex; align-items: center">
                  <img style="
                          max-width: 100%;
                          max-height: 100%;
                          width: 18px;
                          height: 20px;
                        " src="@/assets/img/pdf.png" />
                </div>
              </div>
            </template>
          </el-table-column>
          <el-table-column prop="fStatus" label="信息状态" width="70" align="center">
          </el-table-column>
          <template slot="empty">
            <img style="width: 285px; height: 208px" src="@/assets/img/undata.png" alt="" />
            <div class="pageFlagText">暂时没有数据哦！</div>
          </template>
        </el-table>
        <div class="block" v-if="navigatepageNums > 1" :style="{
          width: treelength ? 'calc(100vw - 430px)' : 'calc(100vw - 241px)',
        }">
          <div class="paginationInfo">
            检索到{{ queryCriteriaData.total }} 条记录 | 显示第
            <span v-if="getList.page == 1">{{ getList.page }}</span><span v-else>{{ 20 * (getList.page - 1) }}</span> -
            <!-- {{ 20 * getList.page }} 条记录 -->

            <span v-if="queryCriteriaData.pages == queryCriteriaData.lastPage"> {{
              queryCriteriaData.total }}</span>
            <span v-else> {{ 20 * getList.page }} </span>
            条记录
          </div>
          <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChanges"
            :current-page="getList.page" :page-size="getList.pageSize" layout="prev, pager, next, jumper"
            :total="queryCriteriaData.total">
          </el-pagination>
        </div>
      </div>
      <!-- 按检测记录新增/编辑 -->
      <div class="fvisible">
        <el-dialog :close-on-click-modal="false" :title="dialogText" v-dialogDrag :visible.sync="dialogTableVisible"
          v-loading="loadingDialog" element-loading-text="拼命加载中" element-loading-spinner="el-icon-loading"
          element-loading-background="rgba(0, 0, 0, 0.2)">
          <div class="" :style="{ height: dialogHeightSample }">
            <el-form :model="formData" :rules="rulesSample" ref="formData">
              <div style="display: flex; width: 100%; margin-top: 15px">
                <el-form-item label="检测类型" prop="fChecktype" :label-width="formLabelWidth">
                  <!-- <el-input v-model="formData.fChecktype" autocomplete="off" placeholder="请输入"></el-input> -->
                  <el-select :disabled="dis" @change="function (item) {
                    return handleChangeSelectId(item);
                  }
                  " v-model="formData.fChecktype" placeholder="请选择">
                    <el-option v-for="(v, i) in Checktype" :key="i" :label="v.fItemName" :value="v">
                    </el-option>
                  </el-select>
                </el-form-item>
                <el-form-item label="检测单位" prop="fLeadercompanyname" :label-width="formLabelWidth">
                  <el-input disabled v-model="formData.fLeadercompanyname" autocomplete="off" placeholder="请输入">
                  </el-input>
                </el-form-item>
              </div>
              <div style="display: flex; width: 100%">
                <el-form-item label="工程部位/用途" :label-width="formLabelWidth">
                  <el-input disabled v-model="formData.fProjecttypename" autocomplete="off" placeholder="请输入">
                  </el-input>
                </el-form-item>
                <el-form-item label="是否进行回弹检测" prop="fIsconcrete" :label-width="formLabelWidth">
                <!-- <el-input disabled v-model="formData.fIsconcrete" autocomplete="off" placeholder="请输入">
                                                    </el-input> -->
                  <el-select :disabled="dis" @change="function (item) {
                    return handleChangeIsconcrete(item);
                  }
                  " v-model="formData.fIsconcrete" placeholder="请选择">
                    <el-option v-for="(v, i) in fIsconcrete" :key="i" :label="v.fItemName" :value="v">
                    </el-option>
                  </el-select>
                </el-form-item>
              </div>

              <div style="display: flex; width: 100%">
                <el-form-item label="回弹检测时间" :rules="
                  formData.fIsconcrete == '是'
                    ? rulesSample.fReportdates
                    : [{ required: false }]
                " :label-width="formLabelWidth">
                  <!--  <el-input v-model="formData.fTestdates" autocomplete="off" placeholder="请输入"></el-input> -->
                  <el-date-picker :disabled="dis" format="yyyy/MM/dd" value-format="yyyy-MM-dd"
                    v-model="formData.fReportdates" type="date" placeholder="选择日期">
                  </el-date-picker>
                </el-form-item>

                <el-form-item label="回弹检测结果" :rules="
                  formData.fIsconcrete == '是'
                    ? rulesSample.fTestresult
                    : [{ required: false }]
                " :label-width="formLabelWidth">
                  <!-- <el-input v-model="formData.fIstrue" autocomplete="off"></el-input> -->
                  <el-select :disabled="dis" v-model="formData.fTestresult" placeholder="请选择">
                    <el-option v-for="(v, i) in IstrueData" :key="i" :label="v.fItemName" :value="v.fItemName">
                    </el-option>
                  </el-select>
                </el-form-item>
              </div>

              <div style="display: flex; width: 100%">
                <el-form-item label="检测情况概述" :label-width="formLabelWidth">
                  <el-input :disabled="dis" v-model="formData.fNote" autocomplete="off"></el-input>
                </el-form-item>
                <!--   -->
                <el-form-item label="记录人" :rules="
                  formData.fIsconcrete == '是'
                    ? rulesSample.fCreateusername
                    : [{ required: false }]
                " :label-width="formLabelWidth">
                  <el-input disabled v-model="formData.fCreateusername" autocomplete="off"></el-input>
                </el-form-item>
              </div>
              <div style="display: flex; width: 100%">
                <!--   -->
                <el-form-item label="回弹记录表" :rules="
                  formData.fIsconcrete == '是'
                    ? rulesSample.fCreateusername
                    : [{ required: false }]
                " :label-width="formLabelWidth" class="enclosure" style="height: 100%">
                  <el-input v-show="false" v-model="formData.fCreateusername" autocomplete="off">
                  </el-input>
                  <div ref="fPhotofilelist" style="
                          height: 25px;
                          line-height: 25px;
                          width: 100%;
                          display: flex;
                          border: 1px solid #d1d7e2;
                          border-radius: 5px;
                          margin: 8px 0 2px 0;
                        ">
                    <div v-for="(item, i) in fPhotofilelist" :key="i" style="margin: 2px 3px; height: 87%"
                      @click="openPdfs(item)">
                      <img style="max-width: 100%; max-height: 100%" src="@/assets/img/pdf.png" />
                    </div>
                  </div>
                  <el-button v-show="!dis" type="primary" icon="el-icon-search" size="small" @click="operation('1')"
                    style="margin: 8px 0 2px 3px">操作</el-button>
                </el-form-item>
                <!--   -->
                <el-form-item label="回弹检测报告" :rules="
                  formData.fIsconcrete == '是'
                    ? rulesSample.fCreateusername
                    : [{ required: false }]
                " :label-width="formLabelWidth" class="enclosure" style="height: 100%">
                  <el-input v-show="false" v-model="formData.fCreateusername" autocomplete="off">
                  </el-input>
                  <div ref="fSourcefilelist" style="
                          height: 25px;
                          line-height: 25px;
                          width: 100%;
                          display: flex;
                          border: 1px solid #d1d7e2;
                          border-radius: 5px;
                          margin: 8px 0 2px 0;
                        ">
                    <div v-for="(v, i) in fSourcefilelist" :key="i" style="margin: 2px 3px; height: 87%"
                      @click="openPdfs(v)">
                      <img style="max-width: 100%; max-height: 100%" src="@/assets/img/pdf.png" />
                    <!-- <img
                        src="@/assets/img/enclosure/imgs.png"
                        alt=""
                        style="height: 90%"
                                                        /> -->
                    </div>
                  </div>
                  <el-button v-show="!dis" type="primary" icon="el-icon-search" size="small" @click="operation('2')"
                    style="margin: 8px 0 2px 3px">操作</el-button>
                </el-form-item>
              </div>
            </el-form>
          </div>

          <div style="height: 40px" v-if="flagNum == 0">
            <div style="position: absolute; right: 5px; bottom: 0">
              <el-button type="primary" @click="submitForm(formData)">保存</el-button>
              <el-button type="warning" @click="resetForm('formData')">重置</el-button>
            </div>
          </div>
        </el-dialog>
      </div>
      <!-- 上传附件  -->
      <div class="Control-1 mechanism_dialog enclosure">
        <el-dialog title="上传附件" v-dialogDrag top="-17vh" :visible.sync="dialogTableVisibleTexts"
          v-loading="loadingDialogTexts" element-loading-text="拼命加载中" element-loading-spinner="el-icon-loading"
          element-loading-background="rgba(0, 0, 0, 0.2)">
          <div class="dialogBody common" :style="{ height: '240px' }">
            <el-upload action="action" ref="upload" list-type="picture-card" :file-list="fPhotofilelist"
              :auto-upload="false" :on-change="handleChange" accept=".pdf">
              <i slot="default" class="el-icon-plus"></i>
              <div style="width: 100%; height: 100%; text-align: center" slot="file" slot-scope="{ file }">
                <div style="
                        width: 100%;
                        height: 100%;
                        display: flex;
                        justify-content: center;
                        align-items: center;
                      " class="images">
                  <img style="max-width: 100%; max-height: 100%" src="@/assets/img/pdf.png" />
                </div>
                <span class="el-upload-list__item-actions">
                  <span title="文件预览" class="el-upload-list__item-preview" @click="openPdf(file)">
                    <i class="el-icon-zoom-in"></i>
                  </span>
                  <span title="删除文件" class="el-upload-list__item-delete" @click="handleRemove(file)">
                    <i class="el-icon-delete"></i>
                  </span>
                </span>
              </div>
            </el-upload>
            <div>
              <div style="position: absolute; right: 5px; bottom: 0">
                <el-button type="primary" @click="submitUpload(enclosureImg)">保存</el-button>
                <el-button type="warning" @click="resetFormv()">关闭</el-button>
              </div>
            </div>
          </div>
        </el-dialog>
      </div>
      <div class="Control-1 mechanism_dialog enclosure">
        <el-dialog title="上传附件" v-dialogDrag top="-17vh" :visible.sync="dialogTableVisibleTexts1"
          v-loading="loadingDialogTexts1" element-loading-text="拼命加载中" element-loading-spinner="el-icon-loading"
          element-loading-background="rgba(0, 0, 0, 0.2)">
          <div class="dialogBody common" :style="{ height: '240px' }">
            <el-upload action="action" ref="upload1" list-type="picture-card" :file-list="fSourcefilelist"
              :auto-upload="false" :on-change="handleChange1" accept=".pdf">
              <i slot="default" class="el-icon-plus"></i>
              <div style="width: 100%; height: 100%; text-align: center" slot="file" slot-scope="{ file }">
                <div style="
                        width: 100%;
                        height: 100%;
                        display: flex;
                        justify-content: center;
                        align-items: center;
                      " class="images">
                  <img style="max-width: 100%; max-height: 100%" src="@/assets/img/pdf.png" />
                </div>
                <span class="el-upload-list__item-actions">
                  <span title="文件预览" class="el-upload-list__item-preview" @click="openPdf(file)">
                    <i class="el-icon-zoom-in"></i>
                  </span>
                  <span title="删除文件" class="el-upload-list__item-delete" @click="handleRemove(file)">
                    <i class="el-icon-delete"></i>
                  </span>
                </span>
              </div>
            </el-upload>
            <div>
              <div style="position: absolute; right: 5px; bottom: 0">
                <el-button type="primary" @click="submitUpload1(enclosureImg)">保存</el-button>
                <el-button type="warning" @click="resetForms()">关闭</el-button>
              </div>
            </div>
          </div>
        </el-dialog>
      </div>
      <div class="Control-2">
        <el-dialog top="4vh" :title="fFileName" v-dialogDrag :visible.sync="dialogPdf">
          <div :style="{ height: dialogHeights }">
            <!-- <iframe :src="pdfUrl" width="100%" height="100%" frameborder="0"></iframe> -->
            <embed :src="`${pdfUrl}#toolbar=0`" hidden="false" type="application/pdf" height="100%" width="100%" />
          </div>
        </el-dialog>
      </div>
    </div>
  </div>
</template>

<script>
import {
  getConcreteCheckTestPageList, // 混凝土回弹业务监管-2-列表页
  upload,
  getCheckTypeByUserList, //检测类型
  getConcreteCheckTestByFid, // 混凝土回弹业务监管-2-详情接口
  saveConcreteCheckTest, // 混凝土回弹业务监管-保存接口
  submitConcreteCheckTest, //提交
} from "@/api/request.js";
// function ie9() {
//   if (navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.split(";")[1].replace(/[ ]/g, "") == "MSIE6.0" || navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.split(";")[1].replace(/[ ]/g, "") == "MSIE7.0" || navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.split(";")[1].replace(/[ ]/g, "") == "MSIE8.0" || navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.split(";")[1].replace(/[ ]/g, "") == "MSIE9.0") {
//     return true
//   } else {
//     return false
//   }
// }
export default {
  inject: ["reload"],
  name: "Home",
  data() {
    return {
      names: "Control-3Text",
      lr_look: null,

      yj_edit: null,
      yj_submit: null,
      // 分页
      navigatepageNums: null, //是否显示分页
      queryCriteriaData: {},
      fnote: "", //回弹设计值是否为空，为空不可新增
      fstatus: "", //信息状态，为空可新增，未提交时可编辑、提交、删除
      formLabelWidth: "110px",
      dialogTableVisibleTexts: false,
      dialogTableVisibleTexts1: false,
      Checktype: [],
      timestamp1: null,
      timestamp2: null,
      operationNum: null,
      enclosureImg: {},
      fPhotofilelist: [],
      fSourcefilelist: [],

      loadingDialogTexts: false,
      loadingDialogTexts1: false,

      attachmentDetails: [],
      attachmentDetails1: [],
      IstrueData: [
        {
          fItemCode: null,
          fItemName: "合格",
        },
        {
          fItemCode: null,
          fItemName: "不合格",
        },
      ], //是否合格
      dialogPdf: false,
      pdfUrl: "",
      fFileName: "",
      equipmentDetailId: null, //列表页id
      dis: false,
      fProjecttypeid: null,

      imgsFId: {
        fId: null, //文件id
      },
      imgsFId1: {
        fId: null, //文件id
      },
      flagNum: 0,
      dateMo: null, //默认日期

      fIsconcrete: [
        {
          fItemCode: null,
          fItemName: "是",
        },
        {
          fItemCode: null,
          fItemName: "否",
        },
      ], //是否进行回弹检测

      disabledText: true,

      dialogHeightSample: "",
      formData: {
        fId: "", //主鍵id
        fProjectid: "", //项目id
        fProjectname: "", //项目简称
        fCompanyname: "", //施工/委托单位简称
        fCompanyid: "", //施工/委托单位id
        fChecktype: "", //检测类型
        fLeadercompanyid: "", //检测单位id
        fLeadercompanyname: "", //检测单位简称
        fReportdates: "", //回弹检测时间
        fTestresult: "", //回弹检测结果
        fProjecttypename: "", //工程部位/用途
        fIsconcrete: "", //是否进行回弹检测
        fNote: "", //检测情况概述
        fCreateuserid: "", //记录人id
        fCreateusername: "", //记录人            "userId": "记录人",//记录人id
        userName: "", //记录人
        recordfiles: [], //删除文件id集合--修改时传
      },
      rulesSample: {
        fChecktype: [
          { required: true, message: "请选择检测类型", trigger: "change" },
        ],
        fLeadercompanyname: [
          { required: true, message: "请输入检测单位", trigger: "blur" },
        ],
        fIsconcrete: [
          { required: true, message: "请选择检测类型", trigger: "change" },
        ],
        fReportdates: [
          { required: true, message: "请选择回弹检测时间", trigger: "change" },
        ],
        fTestresult: [
          { required: true, message: "请选择回弹检测结果", trigger: "change" },
        ],
        fCreateusername: [{ required: true, message: "请选择回弹检测结果" }],
        fPhotofilelist: [{ required: true, message: "请选择回弹记录表" }],
        fSourcefilelist: [{ required: true, message: "请选择回弹检测报告" }],
      },
      // 样品信息
      // 按工程划分新增
      dialogTableVisibleDivide: false,
      loadingDialogDivide: false,

      radio: "待办",
      dialogHeight: "",
      dialogHeights: "",
      fId: null, //当前数据fId

      userInfo: {}, //登录用户
      // 列表
      getList: {
        modelType: "0", // 0代办 1已办  2查询页面
        fCompanyid: null, //机构id
        fUserid: null, //当前登录用户id

        // sublevel: null, //查看下级  1是0否
        sublevel: "0", //查看下级  1是0否
        keyWord: "", //样品编号模糊查询字段
        keyType: "",
        page: 1, //页码
        pageSize: 20, //每页条数
      },
      loading: false,
      // 新增/编辑
      dialogText: "编辑",
      dialogTableVisible: false,
      loadingDialog: false,
      row: null,
      tableData: [], //表格数据列表
      dialogVisible: false,
    };
  },
  created() {
    this.userInfo = JSON.parse(sessionStorage.getItem("userInfo"));
    this.getList.fUserid = this.userInfo.userId;
    this.getList.fCompanyid = this.userInfo.companyId;
  },
  mounted() {
    this.getDate();
    this.getCheckTypeByUserList(); //检测类型 - 根据当前登录用户获取检测类型

    this.getHeight();
    this.getDataList(this.getList);
    this.btnRole(this.names);
  },
  methods: {
    btnRole(name) {
      var btnList = [];
      var ModuleList = JSON.parse(sessionStorage.getItem("ModuleList"));
      if (ModuleList.length > 0) {
        ModuleList.map((item) => {
          if (item.fEncode == name) {
            btnList = item.modulebuttonList;
          }
        });
        var btnStr = [];
        btnList.map((item) => {
          btnStr.push(item.fEncode);
        });
        this.yj_submit = btnStr.includes("yj_submit");

        this.yj_edit = btnStr.includes("yj_edit");
      } else {
        this.yj_submit = true;
        this.yj_edit = true;
      }
    },
    // 检测类型 - change
    handleChangeSelectId(item) {
      this.formData.fChecktype = item.fItemName; //检测类型
      this.formData.fLeadercompanyname = item.fCompanyName; //检测单位简称
      this.formData.fLeadercompanyid = item.fCompanyId; //检测单位id
    },
    handleChangeIsconcrete(item) {
      this.formData.fIsconcrete = item.fItemName; //检测类型
    },

    // 检测类型 - 根据当前登录用户获取检测类型
    getCheckTypeByUserList() {
      getCheckTypeByUserList({ companyId: this.getList.fCompanyid })
        .then((res) => {
          if (res.errcode == 0) {
            this.Checktype = res.data.Checktype;
          } else {
            this.$message.error("检测类型为空", res.msg);
          }
        })
        .catch(() => {
          console.log("检测类型失败");
        });
    },
    // 操作按钮
    operation(num) {
      this.operationNum = num;
      if (num == 1) {
        this.dialogTableVisibleTexts = true;

        this.$refs.fPhotofilelist.style.border = "1px solid #DCDFE6";
      } else if (num == 2) {
        this.$refs.fSourcefilelist.style.border = "1px solid #DCDFE6";
        this.dialogTableVisibleTexts1 = true;
      }
    },
    openPdf(file) {
      this.dialogPdf = true;
      this.pdfUrl = file.url;
      this.fFileName = file.name;
    },
    submitUpload() {
      this.dialogTableVisibleTexts = false;
    },
    submitUpload1() {
      this.dialogTableVisibleTexts1 = false;
    },
    // 移除
    handleRemove(file) {
      if (this.operationNum == 1) {
        this.$refs.upload.handleRemove(file);
        for (let index = 0; index < this.fPhotofilelist.length; index++) {
          if (file.uid == this.fPhotofilelist[index].uid) {
            if (this.fPhotofilelist[index].atta == undefined) {
              this.formData.recordfiles.push({
                fId: this.fPhotofilelist[index].fId,
              });
            } else {
              this.formData.recordfiles.push({
                fId: this.fPhotofilelist[index].atta.fId,
              });
            }
            this.fPhotofilelist.splice(index, 1);
          }
        }
      } else if (this.operationNum == 2) {
        this.$refs.upload1.handleRemove(file);
        for (let index = 0; index < this.fSourcefilelist.length; index++) {
          if (file.uid == this.fSourcefilelist[index].uid) {
            // this.imgsFId1.fId = this.fSourcefilelist[index].atta.fId;
            if (this.fSourcefilelist[index].atta == undefined) {
              this.formData.recordfiles.push({
                fId: this.fSourcefilelist[index].fId,
              });
            } else {
              this.formData.recordfiles.push({
                fId: this.fSourcefilelist[index].atta.fId,
              });
            }
            this.fSourcefilelist.splice(index, 1);
          }
        }
      }
    },
    resetForm(formData) {
      this.$refs[formData].resetFields();
    },
    // 页面切换
    handleSizeChange(val) {
      return val;
    },
    handleCurrentChanges(val) {
      this.getList.page = val;
      this.getDataList(this.getList);
    },
    openPdfs(v) {
      this.dialogPdf = true;
      this.pdfUrl = v.url;
      this.fFileName = v.name;
    },
    openPdfs1(v) {
      this.dialogPdf = true;
      this.pdfUrl = v.url;
      this.fFileName = v.fFileName;
    },
    // 上传文件
    handleChange(res) {
      this.attachmentDetails.push(res);
      this.enclosureImg = new FormData(); //new一个formData事件
      this.enclosureImg.append("folderid", this.timestamp1); //将file属性添加到formData里

      this.enclosureImg.append("file", res.raw); //将file属性添加到formData里

      this.enclosureImg.append("userId", this.userInfo.userId); //将file属性添加到formData里
      this.enclosureImg.append("userName", this.userInfo.realName); //将file属性添加到formData里
      upload(this.enclosureImg).then((i) => {
        i[0]["name"] = res.name;
        i[0]["url"] = res.url;
        this.fPhotofilelist.push(i[0]);
      });
    },
    handleChange1(res) {
      this.attachmentDetails1.push(res);
      this.enclosureImg = new FormData(); //new一个formData事件
      this.enclosureImg.append("folderid", this.timestamp2); //将file属性添加到formData里
      this.enclosureImg.append("file", res.raw); //将file属性添加到formData里
      this.enclosureImg.append("userId", this.userInfo.userId); //将file属性添加到formData里
      this.enclosureImg.append("userName", this.userInfo.realName); //将file属性添加到formData里
      upload(this.enclosureImg).then((i) => {
        i[0]["name"] = res.name;
        i[0]["url"] = res.url;
        this.fSourcefilelist.push(i[0]);
      });
    },
    // 点击当前行变色
    handleCurrentChange(val) {
      this.currentRow = val;
    },
    openDialog(row) {
      this.equipmentDetailId = row.fId;
      this.edit(1);
    },
    openDialog1(row) {
      this.dialogCheckVisible = true;
      this.getCheckList(row.F_EnCode);
    },
    tableRowClassName({ row }) {
      if (row.level == 0 && !row.children) {
        return "fristColor";
      }
    },
    getDetail() {
      if (this.equipmentDetailId != null && this.equipmentDetailId != "") {
        this.edit(1);
        this.dis = true;
      } else {
        return this.$message.error("请先选择需要编辑的数据");
      }
    },

    // 获取当前日期

    getDate() {
      var time = new Date();
      const y = time.getFullYear();
      var m = time.getMonth() + 1 + "";
      m = (m < 10 ? "0" : "") + m;
      var d = time.getDate() + "";
      d = (d < 10 ? "0" : "") + d;

      this.dateMo = `${y}-${m}-${d}`;
    },

    modelType(e) {
      this.fId = "";
      if (e == "待办") {
        this.dialogText = "编辑";
        this.flagNum = 0;
        this.getList.modelType = "0";
        this.disabledText = false;
        this.dis = false;
      } else {
        this.flagNum = 1;
        this.dialogText = "查看";

        this.getList.modelType = "1";
        this.disabledText = true;
        this.dis = true;
      }
      this.getDataList(this.getList);
    },

    // 获取列表数据
    getDataList(data) {
      this.loading = true;
      // 混凝土回弹业务监管-3-列表页
      getConcreteCheckTestPageList(data)
        .then((res) => {
          if (res.errcode == 0) {
            this.loading = false;
            this.tableData = res.data.checkConcreteList.list;
            this.queryCriteriaData = res.data.checkConcreteList;
            this.navigatepageNums =
              this.queryCriteriaData.navigatepageNums.length;
          } else {
            this.$message.error("列表数据获取失败", res.msg);
            this.loading = false;
          }
        })
        .catch(() => {
          console.log("列表数据获取失败");
          this.loading = false;
        });
    },

    // 新增/编辑
    edit() {
      // 编辑
      if (this.equipmentDetailId != null && this.equipmentDetailId != "") {
        this.formData.fId = this.equipmentDetailId;
        this.dialogTableVisible = true;
        this.loadingDialog = true;
        this.recordData = [];
        this.recordData1 = [];

        getConcreteCheckTestByFid({ fId: this.equipmentDetailId })
          .then((res) => {
            if (res.errcode == 0) {
              this.loadingDialog = false;
              this.formData = res.data.lrCheckConcretetest;
              this.formData.fSourcefile =
                res.data.lrCheckConcretetest.fSourcefile;
              this.formData.fPhotofile =
                res.data.lrCheckConcretetest.fPhotofile;
              this.formData.fCreateusername = this.userInfo.realName;
              this.formData.fCreateuserid = this.userInfo.userId;
              this.formData.fReportdates = this.dateMo;

              this.timestamp1 = res.data.lrCheckConcretetest.fPhotofile;
              this.timestamp2 = res.data.lrCheckConcretetest.fSourcefile;
              this.fPhotofilelist = res.data.fPhotofilelist; //检测记录表文件集合
              this.fSourcefilelist = res.data.fSourcefilelist; //强度检测报告文件集合
              this.formData.recordfiles = [];
              this.$nextTick(() => {
                // DOM 更新了
                this.$refs.formData.clearValidate();
              });
            } else {
              this.$message.error("编辑", res.msg);
              this.loadingDialog = false;
            }
          })
          .catch(() => {
            console.log("编辑");
            this.loadingDialog = false;
          });
      } else {
        return this.$message.error("请先选择需要编辑的数据");
      }
    },

    // 选工程划分新增
    engineerings() {
      this.dis = false;
      this.flagNum = 0;
      if (this.equipmentDetailId != null && this.equipmentDetailId != "") {
        this.disabledText = false;
        this.edit(1);
      } else {
        this.$message.error("请选择可编辑数据");
      }
    },

    submitForm() {
      this.formData.userId = this.userInfo.userId;
      this.formData.userName = this.userInfo.realName;
      this.formData.fCreateusername = this.userInfo.realName;
      this.formData.fCreateuserid = this.userInfo.userId;
      this.formData.fProjectid = this.userInfo.projectId; //工程名称id
      this.formData.fProjectname = this.userInfo.projectName; //工程名称简称
      this.formData.fCompanyname = this.userInfo.companyName; //施工/委托单位简称
      this.formData.fCompanyid = this.userInfo.companyId; //施工/委托单位id

      this.$refs.formData.validate(async (valid) => {
        if (valid) {
          if (
            this.fPhotofilelist.length == 0 &&
            this.formData.fIsconcrete == "是"
          ) {
            this.$refs.fPhotofilelist.style.border = "1px solid red";
          } else if (
            this.fSourcefilelist.length == 0 &&
            this.formData.fIsconcrete == "是"
          ) {
            this.$refs.fSourcefilelist.style.border = "1px solid red";
          } else {
            saveConcreteCheckTest(this.formData)
              .then((res) => {
                if (res.errcode == 0) {
                  this.reload();
                  this.$message.success("新增成功");
                } else {
                  this.$message.error("新增失败", res.msg);
                }
              })
              .catch((error) => {
                console.log("新增失败", error);
              });
          }
        } else {
          this.$message.error("请填写必填项");
          return false;
        }
      });
    },

    // 提交
    SubmitText(id) {
      if (id != "" && id != null) {
        this.$confirm("是否继续提交?", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        })
          .then(() => {
            this.loading = true;
            submitConcreteCheckTest({
              fId: id,
              userId: this.userInfo.userId,
              userName: this.userInfo.realName,
            })
              .then((res) => {
                if (res.errcode == 0) {
                  this.loading = false;
                  this.getDataList(this.getList);
                  this.$message.success("提交成功");
                } else {
                  this.$message.error("提交失败", res.msg);
                  this.loading = false;
                }
              })
              .catch(() => {
                console.log("提交失败");
                this.loading = false;
              });
          })
          .catch(() => {
           this.$message("取消提交");
          });
      } else {
        return this.$message.error("请先选择需要提交的数据");
      }
    },

    // 关闭
    resetFormv() {
      this.dialogTableVisible = false;
      this.getDataList(this.getList);
    },
    resetForms() {
      this.dialogTableVisibleDivide = false;
    },

    // 点击当前行
    getRowInfo(e) {

      this.equipmentDetailId = e.fId;
      // this.fId = e.fId;
    },
    // 获取页面容器高度
    getHeight() {
      var h = document.documentElement.clientHeight; //获取页面可见高度
      // var w = document.documentElement.clientWidth; //获取页面可见高度
      this.dialogHeight = h * 0.5 + "px";
      this.dialogHeights = h * 0.888 + "px";
      this.dialogHeightSample = h * 0.4 + "px";
    },
  },
};
</script>

<style scoped>
.printTables {
  background: #fff;
  display: flex;
  justify-content: end;
  padding: 5px;
  margin-top: 10px;
}

a {
  text-decoration: none;
  color: #000;
}

.dialogBody {
  padding: 3px 20px;
  height: 80%;
  overflow-y: auto;
}

.text_table {
  width: 100%;
  overflow-x: auto;
  display: flex;
  flex-direction: column;
  position: relative;
}

.block {
  /* height: 50px; */
  position: fixed;
  padding: 5px 10px;
  width: calc(100vw - 241px);
  bottom: 15px;
  display: flex;
  justify-content: space-between;
  /* align-items: center; */
  border-top: 1px solid #ebeef5;
}

.pageFlagText {
  color: #171a1d;
  font-size: 16px;
}
</style>